//
//  WBNetworkManager-Extension.swift
//  迷你微博
//
//  Created by Json on 2020/3/15.
//  Copyright © 2020 Json. All rights reserved.
//

import Foundation

// 封装网络请求方法
extension WBNetworkManager {
    
    /// 加载数据字典数据
    /// - Parameter completion: 完成回调 list: 字典数据 / 是否成功
    func statusList(completion: @escaping (_ list: [[String: AnyObject]]?, _ isSuccess: Bool)->()) {
        
        let urlString = "https://api.weibo.com/2/statuses/public_timeline.json"
        let params = ["access_token" : "2.00klD_FI0Nfwca4080d6ce2fFVaLHE"]
        
        request(URLString: urlString, parameters: params) { (json, isSuccess) in
            
            // 从json中获取 statuses 字典数据
            let resAny = json as![String: AnyObject]
            let result = resAny["statuses"] as? [[String: AnyObject]]
            completion(result, isSuccess)
        }
    }
}
